package Day2025_04_09;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Demo05 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        Map<Integer, Integer> map;map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int ret = sc.nextInt();
            map.put(ret, map.getOrDefault(ret, 0) + 1);
        }
        int k = map.size();
        if (k > m) {
            System.out.println(-1);
        } else if (k == m) {
            int ret = 0;
            for (Map.Entry<Integer, Integer> set : map.entrySet()) {
                ret = Math.max(set.getValue(), ret);
                System.out.println(ret);
            }
        } else {
            // ???

        }
    }
}
